import Vue from 'vue'
import VueRouter from 'vue-router'
import login from "../components/login.vue"
import home from "../components/home.vue"
import user from "../components/userMGR.vue"
import goods from "../components/GoodsMGR.vue"
import add from "../components/add.vue"
import deleteCom from "../components/delete.vue"
import map from "../components/mapTest.vue"
import orders from "../components/orders.vue"
import child1 from "../components/child1.vue"
import child2 from "../components/child2.vue"

Vue.use(VueRouter)

//component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
const routes = [
    {
        path: '/',
        redirect: "/login"//路由重定向
    },
    {
        path: '/login',
        name: 'login',
        component: login
    },
    {
        path: '/home',
        name: 'home',
        component: home,
        redirect: "/add",
        children: [
            {
                path: '/user',
                name: 'user',
                component: user,
            },
            {
                path: '/goods',
                name: 'goods',
                component: goods,
            },
            {
                path: '/add',
                name: 'add',
                component: add,
            },
            {
                path: '/delete',
                name: 'delete',
                component: deleteCom,
            },
            {
                path: '/map',
                name: 'map',
                component: map,
            },
            {
                path: '/orders',
                name: 'orders',
                component: orders,
                children: [
                    {
                        path: '/child1',
                        name: 'child1',
                        component: child1,
                    },
                    {
                        path: '/child2',
                        name: 'child2',
                        component: child2,
                    },
                ]
            },

        ]
    }

]

const router = new VueRouter({
    routes
})

// router.beforeEach((to, from, next) => {
//    // next()//放行
//    // next("/path")
//   //   debugger
//   // const token=window.sessionStorage.getItem("username")
//   // if(token===""||token===null){
//   //   return  next("/login")
//   // }else{
//   //     next()
//   // }
// })


export default router
